Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sooperlooper per-loop bindings #511

Merged
merged 3 commits into from
Jan 18, 2025

Conversation

pft
Copy link
Contributor

@pft pft commented Jan 4, 2025

Besides ctrl:loop controllers for all per-loop bindable controllers (as previously defined, there may benefit more), also add simple, unnumbered, 'ctrl' controllers to always handle the selected loop.

The mode of the binding to be made is still changed with selected_loop_cc_binding (on the last page of controls).

It is indicated on per-loop bindable controls with (loop number) added to their name, e.g. 'record (3)'

This is updated whenever the loop selection is changed or when selected_loop_cc_binding is set to True.

The earlier implementation was incorrect in multiple aspects:

  1. It bound ctrl:loopnumbers only, and it only worked when the loop was also already the selected one.
    This check is now no longer made.
  2. Checks for current state checked the selected loop, instead of the targeted loop. The targeted loop (chan) is now set and checked.
  3. Selecting a loop with another method than going to the loop selection page and back to another controller page did not work because the UI did not refresh the actual controllers.
    Fixed this by calling
    self.state_manager.send_cuia("refresh_screen", ["control"])
    (I did not find a more direct way)

I noticed I inadvertently added IndexError, in order to not have a naked except (so vscode told me). Revert if this is an incorrect assumption.

Added ctrl:loop controllers for all per-loop bindable controllers (as
previously defined, there may benefit more).

But also simple 'ctrl' controllers to always handle the selected loop.

The mode of the binding to be made is still changed with
selected_loop_cc_binding (on the last page of controls).

It is indicated on per-loop bindable controls with (loop number) added
to their name.

This is updated whenever the loop selection is changed or when
selected_loop_cc_binding is set to True.

The earlier implementation was incorrect in multiple aspects:

1. It bound ctrl:loopnumbers only, and it only worked when the loop was
also already the selected one.
   This check is now no longer made.
2. Checks for current state checked the selected loop, instead of the
targeted loop. The targeted loop (chan) is now set and checked.
2. Selecting a loop with another method than going to the loop
selection page and back to another controller page did not work
because the UI did not refresh the actual controllers.
   Fixed this by calling
      self.state_manager.send_cuia("refresh_screen", ["control"])
   (I did not find a more direct way)
return processor.controllers_dict

def adjust_controller_bindings(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure we should be adding more UI specific code into this backend engine class. We have been seperating UI from backend code. The ctrl screens present a challenge so have not yet been worked on.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is effectively the same as from the old code from line 849—854, with the added condition to set the non-loop-bound controller when selected_loop_cc_binding was True. Since this code has to run in two occasions (when toggling the option and when changing the selected loop), I turned it into a method.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay - We should avoid this but it is already here in the old code so remains an issue to resolve when we split model from view.

except IndexError:
return
processor.refresh_controllers()
self.state_manager.send_cuia("refresh_screen", ["control"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a UI specific call but, maybe this is a reasonable way to handle the challenge of backend changes impacting UI. I wonder whether the selected_loop_cc_binding code might be able to move to a UI class, triggered by this event?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, it is more of a UI change than a back-end change: something effecting what controllers are shown and, more importantly, what to bind to.
Without this, you have to manually refresh the screen.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about this some more, I actually do not exactly follow what you mean. I do not see an event being fired, and I would not know how to add this logic to a new UI class.

The screen refresh is necessary for the new binding logic to work.

Something that probably went unnoticed before single_pedal mode was added to the per-loop binding (which is on the same screen as the loop selectors). For the other controls, you had to switch screens to select a loop and then get back to the screen with the desired controller. Which already does the desired refreshing, and thus the proper binding.

Adding the loop number to the visible name is just frills, and more of a result of me trying to get feedback while trying to get the binding logic right.

I'd really like to get this merged in in some way, so what's the way forward now?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a reasonable way for the model (of which this engine is part) to send events to the view/controller (zyngui).

Copy link
Contributor

@riban-bw riban-bw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks okay. Approving for merge.

@riban-bw riban-bw merged commit a8e5921 into zynthian:vangelis Jan 18, 2025
@riban-bw
Copy link
Contributor

Yikes! I just merged but found issues with the control view gui widget which sends OSC commands to SL to select loops but the controls are not being updated by the correspoding osc message from SL.

@pft
Copy link
Contributor Author

pft commented Jan 18, 2025

That's odd. i could swear I tested this with another program changing the selected loop via osc (my wip ctrldev) and the Zynthian GUI responding correctly.

riban-bw pushed a commit that referenced this pull request Jan 18, 2025
@riban-bw
Copy link
Contributor

I have reverted vangelis. Please fix to work with control view widget.

@pft
Copy link
Contributor Author

pft commented Jan 18, 2025

I just tested this, changing the loop from the widget (recorded via VNC). Controls do look updated:

changing_selected_loop_from_widget

@riban-bw
Copy link
Contributor

When you select loop 6 the record control changes to ON but the widget does not show the loop as recording.

@pft
Copy link
Contributor Author

pft commented Jan 18, 2025

I see, the controls themselves are being replaced, but the values of the controls are not (always) updated, probably when something happens to an unselected loop.

Some complex stuff, I am looking into this. It indeed be nice if controllers just reacted to state changes.

@pft
Copy link
Contributor Author

pft commented Jan 18, 2025

Update: I cannot reproduce or explain this very behaviour, yet.

The opposite I can explain and reproduce: when changing a loop-bound control or state (via CC), selected-loop controls do not update their value, and neither do the widget buttons acquire the required state.

EDIT: just fixed widget buttons getting the right state

@pft
Copy link
Contributor Author

pft commented Jan 18, 2025

Update: I can kind of reproduce this when recording loop 6, removing loop 6, adding loop 6, and going back.
That seems to be a case of not resetting loop controls when removing a loop.

pft added a commit to pft/zynthian-ui that referenced this pull request Jan 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants